package edu.gdut.tiantian.entity;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import edu.gdut.tiantian.utils.DateUtils;


public class Order {
	private String orderId;
	private String recName;
	private String recPhone;
	private String recAddress; 
	private Float totalMoney;
	private Integer status;
	private String statusStr;
	private Date time;
	private String timeStr;
	private User user;
	private List<OrderItem> orderItems = new ArrayList<OrderItem>(); 
	
	public String getTimeStr() {
		timeStr = DateUtils.DateToString(time, "yyyy-MM-dd hh:mm:ss"); 
		return timeStr;
	}
	public void setTimeStr(String timeStr) {
		this.timeStr = timeStr;
	}
	public Date getTime() {
		return time;
	}
	public void setTime(Date time) {
		this.time = time;
	}
	public List<OrderItem> getOrderItems() {
		return orderItems;
	}
	public void setOrderItems(List<OrderItem> orderItems) {
		this.orderItems = orderItems;
	}
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	public String getStatusStr() {
		if(status == 1) {
			statusStr = "已发货";
		}else {
			statusStr = "未发货";
		}
		return statusStr;
	}
	public void setStatusStr(String statusStr) {
		this.statusStr = statusStr;
	}
	public String getOrderId() {
		return orderId;
	}
	public void setOrderId(String orderId) {
		this.orderId = orderId;
	}
	public String getRecName() {
		return recName;
	}
	public void setRecName(String recName) {
		this.recName = recName;
	}
	public String getRecPhone() {
		return recPhone;
	}
	public void setRecPhone(String recPhone) {
		this.recPhone = recPhone;
	}
	public String getRecAddress() {
		return recAddress;
	}
	public void setRecAddress(String recAddress) {
		this.recAddress = recAddress;
	}
	public Float getTotalMoney() {
		totalMoney = 0f;
		for(OrderItem orderItem : orderItems) {
			totalMoney += orderItem.getMoney();
		}
		return totalMoney;
	}
	public void setTotalMoney(Float totalMoney) {
		this.totalMoney = totalMoney;
	}
	@Override
	public String toString() {
		return "Order [orderId=" + orderId + ", recName=" + recName + ", recPhone=" + recPhone + ", recAddress="
				+ recAddress + ", totalMoney=" + totalMoney + ", status=" + status + ", statusStr=" + statusStr
				+ ", time=" + time + ", timeStr=" + timeStr + ", user=" + user + ", orderItems=" + orderItems + "]";
	}
}
